const http = require('http');

http.createServer((request, response) => {
  let body = [];
  request.on('error', err => {
    console.error(err);
  }).on('data', chunk => {
    body.push(chunk);
  }).on('end', () => {
    body = Buffer.concat(body).toString();
    console.log('body:', body);
    response.writeHead(200, { 'Content-Type': 'text/html' });
    const htmlStr =
    `<html maaa=a >
      <head>
        <style>
          body div #myid {
            width: 200px;
            height: 200px;
            background: oringe;
          }
          body div img {
            width: 100px;
            height: 100px;
            background: yellow;
          }
        </style>
      </head>
      <body>
        <div>
            <img id="myid" />
            <img />
        </div>
      </body>
    </html>`
    response.end(htmlStr);
  });
}).listen(8088);

console.log('Server Started')